﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization.Json;
using System.IO;
using mBook.Models;

namespace mBook.DataManager
{
    class DataParser
    {
        public static EbookList parseDataResponseToListEbook(string json)
        {

            var deserializedElements = new EbookList();
            using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(json)))
            {
                var ser = new DataContractJsonSerializer(deserializedElements.GetType());
                deserializedElements = ser.ReadObject(ms) as EbookList;
            }
            return deserializedElements;
            
           
        }

        public static InFoMessagePurchasedFromDownload parseDataResponseToInFoMessagePurchased(string json)
        {
            //InFoMessagePurchasedFromDownload info = JsonConvert.DeserializeObject<InFoMessagePurchasedFromDownload>(json);

            return null;
        }

        public static CategoryList parseDataResponseToCateogries(string json)
        {
            //CategoryList categories = JsonConvert.DeserializeObject<CategoryList>(json);
            //return categories;
            return null;
        }
    }
}
